<template>
	<view>
		<tn-tabbar
		  v-model="currentIndex"
		  :list="tabbarList"
		  activeColor="#838383"
		  inactiveColor="#AAAAAA"
		  activeIconColor="#4169E1"
		  :animation="true"
		  :safeAreaInsetBottom="true"
		  @change="switchTabbar"
		></tn-tabbar>
	</view>
</template>

<script>
	export default {
		name:"tabbar",
		props:{
			curls:{
				type:Number
			} 
		},
		data() {
			return {
				tabbarList: [
				  {
				    title: '首页',
				    activeIcon: 'home-fill',
				    inactiveIcon: 'home',
					url:'/pages/index/index'
				  },
				  {
				    title: '货源',
				    activeIcon: 'search-menu-fill',
				    inactiveIcon: 'search-menu',
					url:'/pages/job/job'
				  },
				  {
				    title: '自选报价',
				    activeIcon: 'vip-fill',
				    inactiveIcon: 'vip',
				    activeIconColor: '#FFFFFF',
				    inactiveIconColor: '#FFFFFF',
					url:'/pages/template/template',
					iconSize: 50,
					out: true
				  },
				  {
				    title: '附近商家',
				    activeIcon: 'discover-fill',
				    inactiveIcon: 'discover',
					url:'/pages/tuniao/tuniao'
				  },
				  {
				    title: '我的',
				    activeIcon: 'computer-fill',
				    inactiveIcon: 'computer',
					url:'/pages/mine/mine'
				  }
				],
				 currentIndex: 0,
			};
		},
		created() {
			let that = this
			 setTimeout(() => {
				 console.log(this.curls)
			      that.currentIndex = this.curls;
			    }, 300); 
		},
		methods:{
			//路径修正
			updatepath(e){
				let that = this
				let tabbarList = this.tabbarList
				tabbarList.forEach(function(item,index){
					if(item.url==e){
						that.currentIndex = index
					}
				});
			},
			// 切换导航
			switchTabbar(index) {
			  this._switchTabbarPage(index)
			},
			// 切换导航页面
			_switchTabbarPage(index) {
			  uni.reLaunch({
			  	url:this.tabbarList[index].url
			  })
			}
		}
	}
</script>

<style lang="scss">

</style>